#include "stdafx.h"
#include "util.h"
//#include "nbase/Qlog.h"

using namespace std;

namespace shared
{
   

    /*std::wstring filepath::GetLocalAppDataDir()
    {
        return nbase::UTF8ToUTF16(Tool::GetLocalAppdataDir());
    }*/



#if 0
    //
    std::map<std::wstring, std::wstring> QCommand::key_value_;

    void QCommand::ParseCommand(const std::wstring &cmd)
    {
#if 0
        std::list<std::wstring> arrays = dui::StringHelper::Split(cmd, L"/");
        for(std::list<std::wstring>::const_iterator i = arrays.begin(); i != arrays.end(); i++)
        {
            std::list<std::wstring> object = dui::StringHelper::Split(*i, L" ");
            assert(object.size() == 2);
            key_value_[ *object.begin() ] = *object.rbegin();
        }
#endif
    }

    std::wstring QCommand::Get(const std::wstring &key)
    {
        std::map<std::wstring, std::wstring>::const_iterator i = key_value_.find(key);
        if (i == key_value_.end())
            return L"";
        else
            return i->second;
    }

    void QCommand::Set(const std::wstring &key, const std::wstring &value)
    {
        key_value_[key] = value;
    }

    void QCommand::Erase(const std::wstring &key)
    {
        key_value_.erase(key);
    }

    bool QCommand::AppStartWidthCommand(const std::wstring &app, const std::wstring &cmd)
    {
        HINSTANCE hInst = ::ShellExecuteW(NULL, L"open", app.c_str(), cmd.c_str(), NULL, SW_SHOWNORMAL);
        return (int)hInst > 32;
    }

    bool QCommand::RestartApp(const std::wstring &cmd)
    {
        wchar_t app[1024] = { 0 };
        GetModuleFileName(NULL, app, 1024);
        HINSTANCE hInst = ::ShellExecuteW(NULL, L"open", app, cmd.c_str(), NULL, SW_SHOWNORMAL);
        return (int)hInst > 32;
    }
#endif
}



